<template>
  <div>
    <nav-header :headerTitle="'添加店铺网址'" :headerNext="'保存'" :navBgColor="'#fff'"
     @tap2next="save"
    ></nav-header>
    <section class="page">
      <div class="header">
        <div class="content">
          <input
            type="text"
            @keyup.enter="keyBoard"
            v-model="show.inputUrl"
            placeholder="请输入如淘宝，京东，拼多多，个人微店等网址"
          />
        </div>
      </div>
      <div class="section">
        <iframe :src="show.iframeUrl" frameborder="0"></iframe>
      </div>
    </section>
  </div>
</template>

<script>
import navHeader from "@/components/NavHeader";
import mixin from "@/utils/mixin";
export default {
  name: "AddShopUrl",
  mixins: [mixin],
  components: {
    navHeader
  },
  data() {
    return {
      show: {
        inputUrl: "",
        iframeUrl: "https://www.baidu.com/"
      }
    };
  },
  created() {
    this.show.iframeUrl=this.$route.query.shopThirdPartyWebUrl;
    this.show.inputUrl=this.$route.query.shopThirdPartyWebUrl;
  },
  mounted() {
    //console.log(this.show.iframeUrl);
  },
  methods: {
     save() {
      this.params = {
        shopId: this.$route.query.shopId,
        shopThirdPartyWebUrl:this.show.iframeUrl
      };
      this.$http.post("shop/processShopThirdPartyWebSite", this.params).then(
        res => {
          console.log(res);
          Toast.success({
            forbidClick: true,
            message: "保存成功",
            onClose: () => {
              this.goUrl("myShop", {});
            }
          });
        },
        err => {
          console.log(err);
        }
      );
    },
    keyBoard: function() {
      if (this.isUrl(this.show.inputUrl)) {
        this.show.iframeUrl = this.show.inputUrl;
      } else {
        Toast({
          forbidClick: true,
          message: "URL地址输入不正确"
        });
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.null32 {
  width: 100%;
  height: 32px;
}
.null78 {
  width: 100%;
  height: 78px;
}
.page {
  margin-top: 86px;
  .header {
    padding-left: 32px;
    padding-right: 32px;
    .content {
      width: 100%;
      height: 112px;
      border-bottom: 2px solid rgba(237, 237, 237, 1);
    }
    input {
      width: 100%;
      height: 45px;
      margin-top: 40px;
      border: none;
      outline: none;
      font-size: 32px;
      font-family: PingFangSC-Regular;
    }
    input::-webkit-input-placeholder {
      color: rgba(200, 200, 200, 1);
    }
  }
  .section {
    position: fixed;
    left: 0px;
    right: 0px;
    top: 200px;
    bottom: 0px;
    iframe {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
